package com.me.model;

import com.me.annotation.Ignore;

import java.math.BigDecimal;
import java.util.UUID;

public class Orderitem {
    private String id;
    private BigDecimal price;
    private int amount;
    private String goodsid;
	private String orderid;
	@Ignore private Goods goods;

	public Orderitem() {
	}

	public Orderitem(Goods g, String orderid) {
		id = UUID.randomUUID().toString();
		price = g.getDPrice();
		amount = 0;
		goodsid = g.getId();
		this.orderid = orderid;

	}

	public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public BigDecimal getDPrice() {
        return price;
    }

	public float getPrice() {
		return price.floatValue();
	}

    public void setPrice(float price) {
        this.price = BigDecimal.valueOf(price);
    }

    public int getAmount() {
        return amount;
    }

    public void setAmount(int amount) {
        this.amount = amount;
    }

    public String getGoodsid() {
        return goodsid;
    }

    public void setGoodsid(String goodsid) {
        this.goodsid = goodsid;
    }

	public String getOrderid() {
		return orderid;
	}

	public void setOrderid(String orderid) {
		this.orderid = orderid;
	}

	public Goods getGoods() {
		return goods;
	}

	public void setGoods(Goods goods) {
		this.goods = goods;
	}

	public void increse() {
		amount++;
	}

	public boolean reduce() {
		if (amount <= 1) {
			return false;
		}
		amount--;
		return true;
	}
}
